<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<base href="<%=basePath%>">
    <LINK rel="stylesheet" media="screen" type="text/css" title="Style" href="css/style.css">
    <script src="js/jquery.js" type="text/javascript"></script>
    <script src="js/simplemodal.js" type="text/javascript"></script>
    <title>Студенты Хогвартса</title>
</head>
<body>
	<div id="background_image">
        <div id="content">
        	<div id="header">
                <ul id="tabs">
                    <li id="interval_1">
                    </li>
                    <li id="houses">
                        <a href="houses">Факультеты</a>
                    </li>
                    <li id="interval_2">
                    </li>
                    <li id="professors">
                        <a href="professors">Профессоры</a>
                    </li>
                    <li id="interval_3">
                    </li>
                    <li id="students" class="current">
                        <a href="students">Студенты</a>
                    </li>
                    <li id="interval_4">
                    </li>
                    <li id="rating">
                        <a href="rating">Рейтинг</a>
                    </li>
                    <li id="interval_5">
                    </li>
                    <li id="subjects">
                        <a href="subjects">Дисциплины</a>
                    </li>
                    <li id="interval_6">
                    </li>
                    <c:if test="${userRole == 3 || userRole == 0}">
	                    <li id="rooms">
	                        <a href="rooms">Общежитие</a>
	                    </li>
                    </c:if>
                    <c:if test="${userRole == 1 || userRole == 2 || userRole == 4 || userRole == 5}">
                    	<li id="blank">
	                    </li>
                    </c:if>
                    <li id="interval_7">
                    </li>
                </ul>
                <div id="message">
                	
                </div>
            </div>
            <div id="book">
                <div id="left_page">
                    <div id="title_left_page">
                        <img src="img/coat_of_arms.png" alt="Coat of Arms of Hogwarts" />
                        <h5>
                            Академия Чародейства и
                            <br />
                            Волшебства "Хогвартс"
                        </h5>
                    </div>
                    <div id="user">
                        <div class="welcome">
                            <h2>
                                <span>Д</span>обро пожаловать,
                                <p class="userName">
                                	${userFN} ${userLN}
                                </p>
                            </h2>
                        </div>
                        <div class="profile">
                            <h4>
								<c:if test="${userRole == 5 && choiceTime==true}">
		                            <a href="choice"><span>В</span>ыбор дисиплин</a>
		                            <br />
	                            </c:if>
								<c:if test="${userRole <= 2 && expulsionTime==true}">
		                            <a href="expulsion"><span>С</span>туденты на отчисление</a>
		                            <br />
	                            </c:if>
                                <a href="messages"><span>С</span>ообщения (${countMess})</a>
                                <br />
                                <c:if test="${userRole < 5}">
	                                <a href="professors/edit?id=${userID}"><span>Р</span>едактировать</a>
	                                <br />
                                </c:if>
                                <a href="#change_password"><span>С</span>менить пароль</a>
                                <br />
                                <a href="logout"><span>В</span>ыход</a>
                            </h4>
                        </div>
                        <c:if test="${userRole == 2 || userRole == 1 || userRole == 0}">
	                        <div class="action">
	                            <h4>
	                                <a href="students/add"><span>Д</span>обавить студента</a>
	                            </h4>
	                        </div>
                        </c:if>
                    </div>
                    <div id="search">
                        <div class="title">
                            <h2><span>П</span>оиск студентов</h2>
                        </div>
                        <form name="search" action="students" method="post">
                            <h2><span>И</span>мя:</h2>
                            <input type="text" name="searchFN" id="first_name_form" class="form_text" value="${searchFN}" />
                            <br/>
                            <h2><span>Ф</span>амилия:</h2>
                            <input type="text" name="searchLN" id="last_name_form" class="form_text" value="${searchLN}" />
                            <br/>
                            <h2><span>К</span>урс:</h2>
                            <select name="searchY" id="year_form" class="form_text">
                            	<c:if test="${searchY == \"\"}"><option value="" selected></option></c:if>
					   			<c:if test="${searchY != \"\"}"><option value=""></option></c:if>
					   			
                            	<c:if test="${searchY == \"1\"}"><option value="1" selected>1</option></c:if>
					   			<c:if test="${searchY != \"1\"}"><option value="1">1</option></c:if>
					   						
					   			<c:if test="${searchY == \"2\"}"><option value="2" selected>2</option></c:if>
					   			<c:if test="${searchY != \"2\"}"><option value="2">2</option></c:if>
					   						
					   			<c:if test="${searchY == \"3\"}"><option value="3" selected>3</option></c:if>
					   			<c:if test="${searchY != \"3\"}"><option value="3">3</option></c:if>
					   						
					   			<c:if test="${searchY == \"4\"}"><option value="4" selected>4</option></c:if>
					   			<c:if test="${searchY != \"4\"}"><option value="4">4</option></c:if>
					   						
					   			<c:if test="${searchY == \"5\"}"><option value="5" selected>5</option></c:if>
					   			<c:if test="${searchY != \"5\"}"><option value="5">5</option></c:if>
					   						
					   			<c:if test="${searchY == \"6\"}"><option value="6" selected>6</option></c:if>
					   			<c:if test="${searchY != \"6\"}"><option value="6">6</option></c:if>
                            </select>
                            <br/>
                            <h2><span>Ф</span>акультет:</h2>
                            <select name="searchH" id="house_form" class="form_text">
                            	<c:if test="${searchH == \"\"}"><option value="" selected></option></c:if>
					   			<c:if test="${searchH != \"\"}"><option value=""></option></c:if>
					   			
                            	<c:if test="${searchH == \"Гриффиндор\"}"><option value="Гриффиндор" selected>Гриффиндор</option></c:if>
					   			<c:if test="${searchH != \"Гриффиндор\"}"><option value="Гриффиндор">Гриффиндор</option></c:if>
					   						
					   			<c:if test="${searchH == \"Пуффендуй\"}"><option value="Пуффендуй" selected>Пуффендуй</option></c:if>
					   			<c:if test="${searchH != \"Пуффендуй\"}"><option value="Пуффендуй">Пуффендуй</option></c:if>
					   						
					   			<c:if test="${searchH == \"Когтевран\"}"><option value="Когтевран" selected>Когтевран</option></c:if>
					   			<c:if test="${searchH != \"Когтевран\"}"><option value="Когтевран">Когтевран</option></c:if>
					   						
					   			<c:if test="${searchH == \"Слизерин\"}"><option value="Слизерин" selected>Слизерин</option></c:if>
					   			<c:if test="${searchH != \"Слизерин\"}"><option value="Слизерин">Слизерин</option></c:if>
                            </select>
                            <br/>
                            <div class="buttons">
                            	<span class="reset">
                            		<a class="form_button" href="students?search=clear">Очистить</a>
                            	</span>
                                <span class="submit"><input class="form_button" type="submit" name="search" value="Найти" /></span>
                            </div>
                        </form>
                    </div>
                </div>
                <div id="right_page">
                    <div id="title_right_page">
                        <img src="img/coat_of_arms.png" alt="Coat of Arms of Hogwarts" />
                        <h3><span>С</span>туденты</h3>
                    </div>
                    <c:if test="${size != 0}">
	                    <div id="list">
	                        <div id="table_content">
	                            <table>
	                                <thead>
	                                    <tr>
	                                        <td class="firstName"><h5><span>И</span>мя</h5></td>
	                                        <td class="lastName"><h5><span>Ф</span>амилия</h5></td>
	                                        <td class="year"><h5><span>К</span>урс</h5></td>
	                                        <td class="house"><h5><span>Ф</span>акультет</h5></td>
	                                    </tr>
	                                </thead>
	                                <c:forEach items="${students}" var="student">
	                                    <tr>
	                                        <td class="firstName"><h4><a href="students/info?id=${student.id}">${student.person.firstName}</a></h4></td>
	                                        <td class="lastName"><h4><a href="students/info?id=${student.id}">${student.person.lastName}</a></h4></td>
	                                        <td class="year"><h4>${student.year}</h4></td>
	                                        <td class="house"><h4>${student.person.house.name}</h4></td>
	                                    </tr>
	                                </c:forEach>                                
	                            </table>
	                        </div>
	                        <ul id="arrows">
	                        	
		                        <li id="left">
		                            <c:if test="${pageBegin != 0}">
		                                <a href="students?page=previous" title="previous">&lt;</a>
		                            </c:if>
		                        </li>
	                            
	                            <li id="number">
	                                <h4>
	                                	<c:if test="${size >= 2}">
			                                ${pageBegin+1} -
		                                	<c:if test="${pageEnd+1 < size}">
		                                		${pageEnd+1}
		                                	</c:if>
		                                	<c:if test="${pageEnd+1 >= size}">
		                                		${size}
		                                	</c:if>
		                                </c:if>
		                                <c:if test="${size < 2}">
		                                	${size}
		                                </c:if>
	                                	(${size})
	                                </h4>
	                            </li>
	                            
		                        <li id="right">
		                            <c:if test="${pageEnd+1 < size}">
		                                <a href="students?page=next" title="next">&gt;</a>
		                            </c:if>
		                        </li>
	                            
	                        </ul>
	                    </div>
                    </c:if>
                    <c:if test="${size == 0}">
	                    <div id="error">
                        	<h2><span>В</span>нимание, обнаружена ошибка:</h2>
                        	<h4>
								По данному критерию студенты не найдены.
							</h4>
						</div>
                    </c:if>
                </div>
            </div>
            <div id="footer">
                <h1>
                    © 2010 Hogwarts. All rights reserved
                    <br />
                    Powered by SMC
                </h1>
            </div>
        </div>
    </div>
    <c:if test="${countMess != 0}">
	    <script type="text/javascript">
	    var temp="<div><img src='img/owl.png' alt=''style='float:left'><h3><a href='messages/info?id="
		    +${unreadedMess}+"'> <span>В</span>ам пришло новое сообщение!</a></h3></div>";
	        $.modal(temp);
	    </script>
	</c:if>
</body>
</html>